import { createRouter, createWebHashHistory } from 'vue-router';

import Recommend from '@/views/recommend.vue';
import Search from '@/views/search.vue';
import Singer from '@/views/singer.vue';
import TopList from '@/views/top-list.vue';
import SingerDetail from '@/views/singer-detail';
import Album from '@/views/album.vue';
import TopDetail from '@/views/top-detail.vue';
import UserCenter from '@/views/user-center.vue';

const routes = [
  {
    path: '/',
    redirect: '/recommend'
  },
  {
    path: '/recommend',
    component: Recommend,
    children: [
      {
        path: ':id',
        component: Album
      }
    ]
  },
  {
    path: '/search',
    component: Search,
    children: [
      {
        path: ':id',
        component: SingerDetail
      }
    ]
  },
  {
    path: '/singer',
    component: Singer,
    children: [
      {
        path: ':id',
        component: SingerDetail
      }
    ]
  },
  {
    path: '/top-list',
    component: TopList,
    children: [
      {
        path: ':id',
        component: TopDetail
      }
    ]
  },
  {
    path: '/user',
    components: {
      // 命名视图中没有写name的出口默认为default
      // 写了key则会去匹配路由出口对应的name
      user: UserCenter
    }
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default router;
